package view;

import java.util.ArrayList;
import java.util.List;

import trans.BaseTransBean;
import trans.DeptTypeTrans;
import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;

import com.opensymphony.xwork2.ActionSupport;
import data.DeptTypeInfoBean;

public class DeptTypeInfoListAction extends ActionSupport{
	private JSONArray deptTypelist;
	private String typeid;
	
	public JSONArray getDeptTypelist() {
		return deptTypelist;
	}

	public void setDeptTypelist(JSONArray deptTypelist) {
		this.deptTypelist = deptTypelist;
	}

	public String getTypeid() {
		return typeid;
	}

	public void setTypeid(String typeid) {
		this.typeid = typeid;
	}

	public String execute(){
		if (deptTypelist == null){
			List<DeptTypeInfoBean> sl = new ArrayList<DeptTypeInfoBean>();
			DeptTypeTrans trans = new DeptTypeTrans(false);
			List<DeptTypeInfoBean> dtl = trans.queryDeptTypeInfo(typeid);
			BaseTransBean.closeDaoSession();
			sl.addAll(dtl);
			JsonConfig jsonConfig = new JsonConfig();
			String[] excludsField = {"callback"}; 
			jsonConfig.setExcludes(excludsField);
			deptTypelist = JSONArray.fromObject(sl, jsonConfig);
		}
		return SUCCESS;
	}
}
